local colour = {
	recipe_tab = "#502C9B",
	material = "#2F619D",
	firsthint = "#E97C07",
	focus 	= "#EA7E07",
	comment = "#6000AA",
	comment = "black", 
	hidden 	= "#000000",

	fire 	= "#EE6314",
	cold 	= "#75CDE8",
	ice 	= "#476BEE",
	electric ="#F1E200",
	poison 	= "#00E60B",
	hurt 	= "#F20000",
    
    black 	= "#000000",
    white 	= "#FFFFFF",
    grey 	= "#505050",
    orange 	= "#CF4F20",
    green 	= "#006600",
    red 	= "#cc3333",
    yellow 	= "#FEDF09",
    magenta = "#d33682",
    violet 	= "#6c71c4",
    purple 	= "#9121DA",
    blue 	= "#268bd2", 
    cyan 	= "#2aa198",
}

local function HexToPercentColour(hex)
    hex = hex:gsub("#","")
    -- 3 -> 1x3
    -- 4 -> 1x4
    -- 6 -> 2x3
    -- 8 -> 2x4
    local step = math.floor(#hex / 3)
    local div = math.pow(16,step)-1
    local num = #hex/step

   	local result = {}
   	for i = 0, num-1 do
   		table.insert(result, tonumber("0x"..hex:sub(i*step+1,(i+1)*step))/ div)
   	end
   	return unpack(result)
end

local function NameToHex(val)
	while themes[val:lower()] ~= nil do
		val = themes[val:lower()]
	end
	return val
end

local function UnpackColour(r, g, b, a)
	if type(r) == "string" then
		local hex = NameToHex(r)
		local alpha = g
		local r,g,b,a = HexToPercentColour(hex)
		if alpha ~= nil then
			a = alpha
		end
		return r,g,b,a
	elseif type(r) == "table" then
		if r.IsVector3 then
			return r.x, r.y, r.z, g
		else
			return r[1],r[2],r[3],g
		end
	else
		return r,g,b,a -- 搁这儿搁这呢?
	end
end

return {
	colour = colour
	UnpackColour = UnpackColour,
}
